package handel

import (
	"github.com/gin-gonic/gin"
	"total-repo/model"
)

func RepoAdd(c *gin.Context) {
	repo_type := c.PostForm("repo_type")
	repo_name := c.PostForm("repo_name")
	repo_address := c.PostForm("repo_address")
	data := model.Repo{
		Repo_Type:    repo_type,
		Repo_Name:    repo_name,
		Repo_Address: repo_address,
	}
	err := model.DB.Create(&data).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
